package cc.jq1024.infrastructure.persistent.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 * 抽奖活动账户表-月次数
 * </p>
 *
 * @author lijiaqiang@ljq1024.cc
 * @since 2024-04-28
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("raffle_activity_account_month")
public class RaffleActivityAccountMonthPO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 自增ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 用户ID
     */
    @TableField("user_id")
    private String userId;

    /**
     * 活动ID
     */
    @TableField("activity_id")
    private Long activityId;

    /**
     * 月（yyyy-mm）
     */
    @TableField("month")
    private String month;

    /**
     * 月次数
     */
    @TableField("month_count")
    private Integer monthCount;

    /**
     * 月次数-剩余
     */
    @TableField("month_count_surplus")
    private Integer monthCountSurplus;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    private LocalDateTime updateTime;


    private final static SimpleDateFormat dateFormatMonth = new SimpleDateFormat("yyyy-MM");
    public static String currentMonth() {
        return dateFormatMonth.format(new Date());
    }


}
